package com.cloud.intercept;

import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @version v1.0
 * @author: TianXiang
 * @description:
 * @date: 2020/10/22
 */
//@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 将切换数据源放在项目拦截器最后一个
        registry
                .addInterceptor(getWorkProgressIntercept())
                .addPathPatterns("/**/importMovie") // 针对导入视频的请求进行拦截
                .order(Integer.MAX_VALUE);
    }

    @Bean
    public WorkProgressIntercept getWorkProgressIntercept() {
        return new WorkProgressIntercept();
    }
}
